<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单管理-车速递</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="../css/mymain.mymain.css">
    <script type="application/javascript" src="../js/jquery-3.3.1.js"></script>
    <script type="application/javascript" src="../js/bootstrap.min.js"></script>
    <script type="application/javascript" src="../layui/layui.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>

</head>
<body style="position: static">

<div id="app" class="bgGray">
    <div data-v-95ac8d30="" class="header3">
        <div data-v-95ac8d30="" class="layout clear">
            <div data-v-95ac8d30="" class="left logo">
                <a data-v-95ac8d30="" href="index.html">
                    <img data-v-95ac8d30="" src="">
                </a>
            </div>
            <div data-v-95ac8d30="" class="header3Nav right">
                <a data-v-95ac8d30="" href="/pagehome/loginsuccess.html">首页</a>
                |<a data-v-95ac8d30="" href="helpCenter.html">帮助中心</a>
                |<a data-v-95ac8d30="" href="/pagehome/index.html" onclick="exitLogin()" id="exitLogin">退出</a>
            </div>
            <div data-v-95ac8d30="" class="header3User right">
                <i data-v-95ac8d30="" class="iconfont icon-phone"></i>
            <span data-v-95ac8d30="" class="sp1" id="telSpan">400-919-8000</span>
            <span data-v-95ac8d30="" class="sp2">欢迎您，</span>
            <span data-v-95ac8d30="" class="sp3" id="nameSpan"></span>
        </div>
        </div>
    </div>
    <div class="userInfo">
        <div class="layout">
            <div class="userInfoCom clear">
                <div class="userInfoL left">
                    <div data-v-1cae2c34="" class="userNav">
                        <dl data-v-1cae2c34="" class="userMsg">
                            <dt data-v-1cae2c34="">
                                <img data-v-1cae2c34="" src="">
                            </dt>
                            <dd data-v-1cae2c34="">
                                <p data-v-1cae2c34=""></p>
                                <p data-v-1cae2c34="" class="p5 pp" style="">普卡会员</p>
                            </dd>
                        </dl>
                        <ul data-v-1cae2c34="" class="manNav">
                            <li data-v-1cae2c34="">
                                <a data-v-1cae2c34="" href="/mymain/mymain.html" class="sel">订单管理</a>
                            </li>
                             <li data-v-1cae2c34="">
                                 <a data-v-1cae2c34="" href="/mymain/myinfo.html" class="">个人信息</a>
                             </li>
                        </ul>
                    </div>
                </div>
                <div class="userInfoR right">

                    <div class="orderManage manage">
                        <div class="orderManageTit manageTit clear">
                            <div class="left tit">订单管理</div>
                        </div>
<!--                        <div class="orderType clear type">-->
<!--                            <div class="sel">全部订单</div>-->
<!--                        </div>-->

                        <div class="orderList list">

                            <table class="layui-hide" id="orderTable" lay-filter="orderTable"></table>
                            <script type="text/html" id="barDemo">
                                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="deleteOrder">删除</a>
                            </script>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div data-v-3aaf9db2="" class="footer2">
        <div data-v-3aaf9db2="" class="layout clear">
            <div data-v-3aaf9db2="" class="d1">
                <a data-v-3aaf9db2="" href="about.html">关于车速递</a></div></div></div>
   </div>

    <script>
        var storage = window.sessionStorage;

        layui.use(['jquery', 'table', 'layer', 'form'], function () {
            // 加载layui模块，使用其推荐的【预先加载】方式，详见官网【模块规范】一节
            var $ = layui.$;
            var layer = layui.layer;
            var table = layui.table;

            var item = storage.getItem('user');
            var user = JSON.parse(item);
            if (user != null) {
                $("#nameSpan").text(user.name);
                $("#telSpan").text(user.tel);
            } else {
                $("#successLobel").hide();
            }

            //加载数据
            table.render({
                elem: '#orderTable'
                , url: '/getMyOrders/' + user.uid
                , cellMinWidth: "80%"
                , cols: [[
                    {field: 'id', width: "10%", title: '订单编号', sort: true}
                    ,{field: 'carName', width: "20%", title: '车辆名称', sort: true}
                    ,{field: 'oprice', width: "10%", title: '金额', sort: true}
                    , {field: 'type', width: "10%", title: '类型'}
                    , {field: 'qcAddr', width: "20%", title: '取车地址', sort: true}
                    , {field: 'hcAddr', width: "20%", title: '还车地址', sort: true}
                    , {field: 'status', width: "12%", title: '状态', sort: true}
                    , {toolbar: '#barDemo', title: '操作', width: "8%"}
                ]]
                , id: 'orderTable'
            });

            table.on('tool(orderTable)', function (obj) {
                //获取当前行数据 以及 lay-event的值
                var data = obj.data;
                var event = obj.event;

                // 删除事件
                if (event == 'deleteOrder') {
                    layer.confirm('确定删除该订单记录吗？', function(index) {
                        // ajax方式删除
                        $.ajax({
                            url: '/deleteMyOrder/' + data.id,
                            type: "DELETE",
                            dataType: 'json',
                            success: function(data) {
                                if (data) {
                                    layer.msg('删除成功');
                                    table.reload('orderTable');
                                } else {
                                    layer.msg('删除失败');
                                }
                            },
                            error: function() {
                                console.log("ajax error");
                            }
                        });
                        layer.close(index);
                    });
                }
            });

        });

        function exitLogin(){
            storage.setItem('user', null);
        }
    </script>
</body>
</html>